<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/common/mytags.jsp"%>
<html>
<head>

<%@ include file="/common/easyui.jsp"%>

<script type="text/javascript">
	$(document).ready(function() {
		//设置查询
		$.getJSON("${ctx}/adminManage/auto/autoDb/listForAjax.do", function(json) {
			var firstDbid;
			if(json.rows.length>0){
				firstDbid=json.rows[0].id;
				loadList(firstDbid);
			}	
			$('#dbId').combogrid({
				data : json.rows,
				panelWidth : 500,
				idField:'id',
				textField:'dbName',
				value:firstDbid,
				editable:false,
				columns:[[
					{field : 'id',title : '主键',hidden:true},      
					{field : 'dbName',title : '数据库名'},
					{field : 'dbType',title : '类型'},
					{field : 'dbAccount',title : '账号'},
					{field : 'dbUrl',title : '地址'}
				]],
				onSelect:function(index,row){
					loadList(row.id);
				}
			});
		});
	});

	function doAdd() {
	}

	function doUpdate() {
		var obj = $('#dataTable').treegrid('getChecked');
	}
	
	function doDelete() {
		var obj = $('#dataTable').treegrid('getChecked');
	}
	
	function loadList(dbId) {
		$('#dataTable').treegrid({
			title : '数据库',
			loadMsg:'数据正在加载中...',
			idField : 'id',
			treeField : 'className',
			url : '${ctx}/adminManage/auto/autoDbClass/listForAjax.do',
			queryParams :{dbId : dbId},
			//queryParams :{dbId : $('#dbId').combogrid('getValue')},
			columns : [[
						{field : 'id',title : '分类编号',hidden:true},
						{field : 'className',title : '分类名称'},
						{field : 'classPackage',title : '数据库包'},
						{field : 'urlPath',title : '路径'},
						{field : 'ordernum',title : '排序值(由大到小排列)'},
						{field : 'opt',title : '操作',formatter:function(value,rowData){
							var show="<a href=\"#\" onclick=\"addSon('"+rowData.id+"')\">添加下一级</a> 上 下";
							return show;
						}}
						]],
			pagination : false,	
			toolbar: '#tb',
			striped : true,
			singleSelect : true,
			rownumbers : true
		});
	}
	
	function addSon(id){
		alert(id);
	}
</script>
</head>

<body class="easyui-layout">
<div region="center" border="false">
	<table id="dataTable" style="width:100%;height:100%"></table>
	<!-- 查询条件和管理按钮 -->
	<div id="tb" style="padding:5px;height:auto"> 
		<div>    
			所属数据库: <input id="dbId" class="easyui-combogrid" name="dbId" style="width:250px" />
	    </div>       
	    <div style="margin-bottom:5px">    
	        <a class="easyui-linkbutton" plain="true" iconCls="icon-add" onclick="doAdd()">新增</a>    
	        <a class="easyui-linkbutton" plain="true" iconCls="icon-edit" onclick="doUpdate()">修改</a>    
	        <a class="easyui-linkbutton" plain="true" iconCls="icon-remove" onclick="doDelete()">删除</a>    
	    </div>    
	</div> 
	
	<div id="editDiv" style="padding: 5px; display: none"></div>
</div>
</body>
</html>